package view;

import java.awt.EventQueue;
import java.awt.KeyEventDispatcher;
import java.awt.KeyboardFocusManager;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.WindowEvent;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import javax.swing.JToolBar;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import storage.ManageData;
import utils.CommandGenerator;
import utils.ScreenAdjustment;
import control.Alert;
import control.BudgetManager;
import control.CategoryManager;
import control.ExpenseManager;
import control.IncomeManager;
import control.LoanManager;
import control.MemberManager;
import control.PaymentMethodManager;
import control.Shell;
import control.ViewPanelManager;

import javax.swing.JSeparator;
import java.awt.Font;

import javax.swing.ImageIcon;

//@author A0081236L
public class MainGUI extends JFrame{

	private JPanel contentPane;

	private MemberManager _memberMan = new MemberManager(null);
	private CategoryManager _catMan = new CategoryManager(null);
	private PaymentMethodManager _payMan = new PaymentMethodManager(null);
	private ExpenseManager _expenseMan = new ExpenseManager(_memberMan,_payMan);
	private IncomeManager _incomeMan = new IncomeManager(_memberMan);
	private LoanManager _loanMan = new LoanManager(_memberMan,_catMan, _payMan, _expenseMan, _incomeMan);
	private BudgetManager _budgetMan = new BudgetManager(_expenseMan,_incomeMan,_loanMan);
	private Alert _alert = new Alert(_budgetMan,_expenseMan,_incomeMan);
	
	private ViewPanelManager _tabPanelMgr = new ViewPanelManager();
	private SidePane _sidePane = new SidePane(_budgetMan,_alert);
	
	private Shell _shell = new Shell(_alert, _budgetMan,_expenseMan,_incomeMan,_loanMan,_memberMan,_catMan,_payMan,_sidePane);
	private OverviewPanel panel_overview = new OverviewPanel(_budgetMan, _incomeMan, _expenseMan);
	private ExpenseManagerPanel panel_xpnManager = new ExpenseManagerPanel(_expenseMan,_shell,_memberMan,_catMan,_payMan, _sidePane,_tabPanelMgr);
	private IncomeManagerPanel panel_incomeManager = new IncomeManagerPanel( _incomeMan, _shell,_memberMan, _sidePane, _tabPanelMgr);
	private LoanManagerPanel panel_loanManager = new LoanManagerPanel( _expenseMan, _shell, _memberMan, _catMan, _payMan, _loanMan, _sidePane, _tabPanelMgr);
	private ViewBudgetPanel panel_budgetSituation = new ViewBudgetPanel(_expenseMan, _incomeMan, _loanMan, _memberMan, _catMan, _payMan, _shell);
	private CategoryManagerPanel panel_categoryManager = new CategoryManagerPanel( _catMan, _shell, _tabPanelMgr);
	private MemberManagerPanel panel_memManager = new MemberManagerPanel( _memberMan, _shell, _tabPanelMgr);
	private PaymentTypeManagerPanel panel_payManager = new PaymentTypeManagerPanel( _payMan, _shell, _tabPanelMgr);
	private AlertManagerPanel panel_alertManager = new AlertManagerPanel(_sidePane, _alert);
	private BudgetSelectionPanel panel_budgetSelection = new BudgetSelectionPanel(_incomeMan,_budgetMan,_sidePane);
	private ViewReportPanel panel_viewReport = new ViewReportPanel(_expenseMan, _shell, _memberMan, _catMan, _incomeMan, _loanMan, _payMan);
	private InvestmentPlanPanel panel_investmentPlan = new InvestmentPlanPanel(_expenseMan, _shell, _incomeMan,_memberMan, _loanMan, panel_loanManager,_tabPanelMgr); 
	private AboutPanel panel_aboutWindow = new AboutPanel();
	private CLIHelpPanel panel_cliHelp = new CLIHelpPanel();

	JFrame frame_memMan = new JFrame();
	JFrame frame_categoryMan = new JFrame();
	JFrame frame_payMan = new JFrame();
	JFrame frame_alertSetting = new JFrame();
	JFrame frame_budgetSetting = new JFrame();
	JFrame frame_aboutWindow = new JFrame();
	JFrame frame_cliHelp = new JFrame();
	public JFrame curWindow = null;
	
	private JTextField txt_cli;
	
	private JTabbedPane tabbedPane;
	
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		try {
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		} catch (ClassNotFoundException | InstantiationException
				| IllegalAccessException | UnsupportedLookAndFeelException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					MainGUI frame = new MainGUI();
					frame.setVisible(true);
					frame.setTitle("EzXpns");
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}
	
    /**
     * 
     * @Precondition 
     * @Postcondition 
     */
    public void closeWindow() {
        WindowEvent wev = new WindowEvent(this, WindowEvent.WINDOW_CLOSING);
        Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(wev);
    }
	

	/**
	 * Create the frame.
	 */

    //@author A0081236L
	public MainGUI(){        
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.addWindowListener(new java.awt.event.WindowAdapter()
        {
        	public void windowClosing(WindowEvent e) {
        		int selection = JOptionPane.showConfirmDialog(null, "Do you want to save any unsaved data before exiting?", "Warning", JOptionPane.YES_NO_OPTION);
        		if(selection==JOptionPane.YES_OPTION)
        		{
        			saveAll();
        			JOptionPane.showMessageDialog(null, "All Data Saved");
        		}
			}
        });
		setBounds(ScreenAdjustment.getAlignCenterX(1144), ScreenAdjustment.getAlignCenterY(690), 1144, 690);
		JMenuBar menuBar = new JMenuBar();
		setJMenuBar(menuBar);
		contentPane = new JPanel();
		//contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);

		JMenu mnFile = new JMenu("File");
		mnFile.setMnemonic('F');
		menuBar.add(mnFile);
		//JMenuItem CLI = new JMenuItem("Open CLI");
		//file.add(CLI);
		JMenuItem save = new JMenuItem("Save   Ctrl+S");
		save.setIcon(new ImageIcon(MainGUI.class.getResource("/images/save16.png")));
		mnFile.add(save);
		
		JSeparator separator_2 = new JSeparator();
		mnFile.add(separator_2);
		
		JMenuItem mntmClearAllData = new JMenuItem("Delete All Saved Data");
		mntmClearAllData.setIcon(new ImageIcon(MainGUI.class.getResource("/images/delete16.png")));
		mnFile.add(mntmClearAllData);
		mntmClearAllData.addActionListener(new ActionListener(){

			@Override
			public void actionPerformed(ActionEvent e) {
				int selection = JOptionPane.showConfirmDialog(null, "Are you sure to delete all saved data?\n This operation cannot be undone.", "Warning", JOptionPane.YES_NO_OPTION);
				if(selection==JOptionPane.YES_OPTION)
				{
					ManageData.cleanAllData();
					JOptionPane.showMessageDialog(null, "All Saved Data Deleted");
					_tabPanelMgr.updateAll();
				}
			}
			
		});
		
		JSeparator separator_1 = new JSeparator();
		mnFile.add(separator_1);
		JMenuItem exit = new JMenuItem("Exit     Ctrl+Q");
		exit.setIcon(new ImageIcon(MainGUI.class.getResource("/images/exit16.png")));
		mnFile.add(exit);
		save.addActionListener(new ActionListener(){

			@Override
			public void actionPerformed(ActionEvent e) {
				if(saveAll())
				{
					//pop up window
				}
				else
				{
					//pop up window
				}
				
			}
			
		});
		
		exit.addActionListener(new ActionListener(){

			@Override
			public void actionPerformed(ActionEvent e) {			
				closeWindow();
			}
			
		});
		

		JMenu menu_edit = new JMenu("Edit");
		menu_edit.setMnemonic('E');
		menuBar.add(menu_edit);	
		JMenuItem menu_undo = new JMenuItem("Undo   Ctrl+Z");
		menu_undo.setIcon(new ImageIcon(MainGUI.class.getResource("/images/undo16.png")));
		menu_edit.add(menu_undo);
		JMenuItem menu_redo = new JMenuItem("Redo   Ctrl+R");
		menu_redo.setIcon(new ImageIcon(MainGUI.class.getResource("/images/redo16.png")));
		menu_edit.add(menu_redo);
		menu_undo.addActionListener(new ActionListener(){
			@Override
			public void actionPerformed(ActionEvent e) {
				undo();
			}
		});
		menu_redo.addActionListener(new ActionListener(){
			@Override
			public void actionPerformed(ActionEvent e) {
				redo();
			}
		});
		
		
		JMenu menu_settings = new JMenu("Settings");
		menu_settings.setMnemonic('S');
		menuBar.add(menu_settings);

		JMenuItem alertSelection = new JMenuItem("Alert                        Ctrl+A");
		alertSelection.setIcon(new ImageIcon(MainGUI.class.getResource("/images/alert.png")));
		menu_settings.add(alertSelection);
		alertSelection.addActionListener(new ActionListener(){
			@Override
			public void actionPerformed(ActionEvent e) {
        		openSettingsMgrFrame(frame_alertSetting);
			}
		});
		
		JMenuItem budgetSelection = new JMenuItem("Budget                    Ctrl+B");
		budgetSelection.setIcon(new ImageIcon(MainGUI.class.getResource("/images/budget.png")));
		menu_settings.add(budgetSelection);
		budgetSelection.addActionListener(new ActionListener(){
			@Override
			public void actionPerformed(ActionEvent e) {
        		openSettingsMgrFrame(frame_budgetSetting);
			}
		});
		
		JSeparator separator = new JSeparator();
		menu_settings.add(separator);
		
		JMenuItem member = new JMenuItem("Member                  Ctrl+M");
		member.setIcon(new ImageIcon(MainGUI.class.getResource("/images/mem16.png")));
		menu_settings.add(member);
		member.addActionListener(new ActionListener(){
			@Override
			public void actionPerformed(ActionEvent e) {
        		openSettingsMgrFrame(frame_memMan);
			}
		});
		
		JMenuItem category = new JMenuItem("Category                 Ctrl+C");
		category.setIcon(new ImageIcon(MainGUI.class.getResource("/images/category.png")));
		menu_settings.add(category);
		category.addActionListener(new ActionListener(){
			@Override
			public void actionPerformed(ActionEvent e) {
        		openSettingsMgrFrame(frame_categoryMan);
			}
		});
		
		JMenuItem payType = new JMenuItem("Payment Method   Ctrl+P");
		payType.setIcon(new ImageIcon(MainGUI.class.getResource("/images/cash.png")));
		menu_settings.add(payType);
		payType.addActionListener(new ActionListener(){
			@Override
			public void actionPerformed(ActionEvent e) {
        		openSettingsMgrFrame(frame_payMan);
			}
		});
		
		JMenu menu_help = new JMenu("Help");
		menu_help.setMnemonic('H');
		menuBar.add(menu_help);	
		
		JMenuItem mntmCliHelp = new JMenuItem("CLI Help           F1");
		mntmCliHelp.setIcon(new ImageIcon(MainGUI.class.getResource("/images/help16.png")));
		menu_help.add(mntmCliHelp);
		mntmCliHelp.addActionListener(new ActionListener(){

			@Override
			public void actionPerformed(ActionEvent e) {
        		openSettingsMgrFrame(frame_cliHelp);
			}
			
		});
		
		JMenuItem about = new JMenuItem("About     Ctrl+W");
		about.setIcon(new ImageIcon(MainGUI.class.getResource("/images/about16.png")));
		menu_help.add(about);
		about.addActionListener(new ActionListener(){
			@Override
			public void actionPerformed(ActionEvent e) {
				openSettingsMgrFrame(frame_aboutWindow);
			}
		});
		
		
		setupSettingsFrames();
		
		contentPane.setLayout(null);
		
		tabbedPane = new JTabbedPane(JTabbedPane.TOP);
		tabbedPane.setBounds(0, 0, 850, 590);
		contentPane.add(tabbedPane);
		Font tabbedPanefont = new java.awt.Font("Century Gothic", Font.BOLD, 11);
		tabbedPane.setFont(tabbedPanefont);
		tabbedPane.addTab("Overview (O)", new ImageIcon(MainGUI.class.getResource("/images/overview32.png")), panel_overview, null);
		panel_overview.setLayout(null);
		tabbedPane.addTab("Expense (E)", new ImageIcon(MainGUI.class.getResource("/images/xpn32.png")), panel_xpnManager, null);
		panel_xpnManager.setLayout(null);	
		tabbedPane.addTab("Income (I)", new ImageIcon(MainGUI.class.getResource("/images/income32.png")), panel_incomeManager, null);
		panel_incomeManager.setLayout(null);	
		tabbedPane.addTab("Loan (L)", new ImageIcon(MainGUI.class.getResource("/images/loan32.png")), panel_loanManager, null);
		panel_loanManager.setLayout(null);
		tabbedPane.addTab("Financial Situation (F)", new ImageIcon(MainGUI.class.getResource("/images/view.png")), panel_budgetSituation, null);
		panel_budgetSituation.setLayout(null);
		tabbedPane.addTab("Report (G)", new ImageIcon(MainGUI.class.getResource("/images/report32.png")), panel_viewReport, null);
		panel_viewReport.setLayout(null);
		tabbedPane.addTab("Investment Plan (H)", new ImageIcon(MainGUI.class.getResource("/images/investment32.png")), panel_investmentPlan, null);
		panel_investmentPlan.setLayout(null);
		
		_sidePane.setBounds(855, -9, 273, 631);
		contentPane.add(_sidePane);
		
		JToolBar bottomToolBar = new JToolBar();
		bottomToolBar.setFloatable(false);
		bottomToolBar.setBounds(0, 590, 95, 32);
		contentPane.add(bottomToolBar);
		
		JButton tlb_save = new JButton("");
		tlb_save.setIcon(new ImageIcon(MainGUI.class.getResource("/images/Save2.png")));
		tlb_save.setFont(new Font("Stencil", Font.PLAIN, 14));
		JButton tlb_undo = new JButton("");
		tlb_undo.setIcon(new ImageIcon(MainGUI.class.getResource("/images/Undo.png")));
		tlb_undo.setFont(new Font("Stencil", Font.PLAIN, 14));
		JButton tlb_redo = new JButton("");
		tlb_redo.setIcon(new ImageIcon(MainGUI.class.getResource("/images/Redo.png")));
		tlb_redo.setFont(new Font("Stencil", Font.PLAIN, 14));
		bottomToolBar.add(tlb_save);
		bottomToolBar.add(tlb_undo);
		bottomToolBar.add(tlb_redo);
		tlb_undo.addActionListener(new ActionListener(){
			@Override
			public void actionPerformed(ActionEvent e) {
				undo();
			}
		});
		tlb_redo.addActionListener(new ActionListener(){
			@Override
			public void actionPerformed(ActionEvent e) {
				redo();
			}
		});
		tlb_save.addActionListener(new ActionListener(){
			@Override
			public void actionPerformed(ActionEvent e) {
				saveAll();
			}
		});
		
		txt_cli = new JTextField();
		txt_cli.setBounds(98, 592, 717, 28);
		contentPane.add(txt_cli);
		txt_cli.setColumns(10);		
		txt_cli.addKeyListener(new KeyAdapter() {
			@Override
			public void keyTyped(KeyEvent e) {
				if(e.getKeyChar() == KeyEvent.VK_ENTER)
				{
					processCLI(txt_cli);
				}	
			}
			@Override
			public void keyReleased(KeyEvent e) {
				if(e.getKeyCode() == KeyEvent.VK_UP)
				{
					String cmd = _shell.upCmd();
					if(cmd!=null)
					{
						txt_cli.setText(cmd);
					}
				}
				if(e.getKeyCode() == KeyEvent.VK_DOWN)
				{
					String cmd = _shell.downCmd();
					if(cmd!=null)
					{
						txt_cli.setText(cmd);
					}
				}
			}
		});
		
		JButton btn_sendCmd = new JButton("");
		btn_sendCmd.setIcon(new ImageIcon(MainGUI.class.getResource("/images/Forward.png")));
		btn_sendCmd.setBounds(814, 595, 36, 24);
		contentPane.add(btn_sendCmd);
		btn_sendCmd.setContentAreaFilled(false);
		btn_sendCmd.setFocusable(false);
		btn_sendCmd.addActionListener(new ActionListener(){
			@Override
			public void actionPerformed(ActionEvent e) {
				processCLI(txt_cli);
			}
			
		});

        KeyboardFocusManager keyFocusMgr = KeyboardFocusManager.getCurrentKeyboardFocusManager();
        keyFocusMgr.addKeyEventDispatcher(new MyDispatcher());
		//register panels
        _tabPanelMgr.register(panel_overview);
        _tabPanelMgr.register(panel_xpnManager);
        _tabPanelMgr.register(panel_incomeManager);
        _tabPanelMgr.register(panel_loanManager);
        _tabPanelMgr.register(panel_viewReport);
        _tabPanelMgr.register(panel_budgetSituation);
        _tabPanelMgr.register(panel_investmentPlan);
	}

	//@author A0098891H
    private class MyDispatcher implements KeyEventDispatcher {
        @Override
        public boolean dispatchKeyEvent(KeyEvent e) {
            if (e.getID() == KeyEvent.KEY_PRESSED) {
            	if ((e.getKeyCode() == KeyEvent.VK_Z) && e.isControlDown()) 
            	{
					undo();
                }
            	if ((e.getKeyCode() == KeyEvent.VK_R) && e.isControlDown()) 
            	{
					redo();
                }
            	if ((e.getKeyCode() == KeyEvent.VK_S) && e.isControlDown()) 
            	{
					saveAll();
                }
            	if ((e.getKeyCode() == KeyEvent.VK_C) && e.isControlDown()) 
            	{
            		openSettingsMgrFrame(frame_categoryMan);
                }
            	if ((e.getKeyCode() == KeyEvent.VK_P) && e.isControlDown()) 
            	{
            		openSettingsMgrFrame(frame_payMan);
                }
            	if ((e.getKeyCode() == KeyEvent.VK_M) && e.isControlDown()) 
            	{
            		openSettingsMgrFrame(frame_memMan);
                }
            	if ((e.getKeyCode() == KeyEvent.VK_O) && e.isControlDown()) 
            	{
            		gotoTabOverview();
                }
            	if ((e.getKeyCode() == KeyEvent.VK_E) && e.isControlDown()) 
            	{
            		gotoTabExpense();
                }
            	if ((e.getKeyCode() == KeyEvent.VK_I) && e.isControlDown()) 
            	{
            		gotoTabIncome();
                }
            	if ((e.getKeyCode() == KeyEvent.VK_L) && e.isControlDown()) 
            	{
            		gotoTabLoan();
                }
            	if ((e.getKeyCode() == KeyEvent.VK_B) && e.isControlDown()) 
            	{
            		openSettingsMgrFrame(frame_budgetSetting);
                }
            	if ((e.getKeyCode() == KeyEvent.VK_A) && e.isControlDown()) 
            	{
            		openSettingsMgrFrame(frame_alertSetting);
                }
            	if ((e.getKeyCode() == KeyEvent.VK_F) && e.isControlDown()) 
            	{
            		gotoTabSearch();
                }
            	if ((e.getKeyCode() == KeyEvent.VK_G) && e.isControlDown()) 
            	{
            		gotoTabReport();
                }
            	if ((e.getKeyCode() == KeyEvent.VK_H) && e.isControlDown()) 
            	{
            		gotoTabInvest();
                }
            	if ((e.getKeyCode() == KeyEvent.VK_W) && e.isControlDown()) 
            	{
            		openSettingsMgrFrame(frame_aboutWindow);
                }
            	if ((e.getKeyCode() == KeyEvent.VK_Q) && e.isControlDown()) 
            	{
            		closeWindow();
                }
            	if (e.getKeyCode() == KeyEvent.VK_F1) 
            	{
            		openSettingsMgrFrame(frame_cliHelp);
                }
            	
            } else if (e.getID() == KeyEvent.KEY_RELEASED) {
            	if((e.getKeyCode() == KeyEvent.VK_TAB))
            	{
            		txt_cli.requestFocus();
            	}
            } else if (e.getID() == KeyEvent.KEY_TYPED) {
            	
            }
            return false;
        }
    }
	
	/**
	 * 
	 * @return
	 * @Precondition 
	 * @Postcondition 
	 */
	public boolean saveAll()
	{
		if(
		_expenseMan.saveAll()
		&&_incomeMan.saveAll()
		&&_loanMan.saveAll()
		&&_budgetMan.saveAll()
		&&_memberMan.saveAll()
		&&_catMan.saveAll()
		&&_payMan.saveAll()
		)
		{
			_sidePane.appendRecent("All Data Saved.\n");
			return true;
		}
		return false;
	}

	public void processCLI(JTextField textField)
	{
		String cmd = textField.getText();
		int res = _shell.readCmd(cmd);
		updateCRUDPanels(res);
		_sidePane.update();
		_tabPanelMgr.updateAll();
		textField.setText("");
	}
	
	public void updateCRUDPanels(int shellRes)
	{
		if(shellRes==-1)
		{
			return;
		}
		switch(shellRes)
		{
		case Shell.CATEGORY:
			panel_categoryManager.update();
			break;
		case Shell.MEMBER:
			panel_memManager.update();
			break;
		case Shell.PAYMENT_METHOD:
			panel_payManager.update();
			break;
		}
		panel_xpnManager.updateAll();
		panel_incomeManager.updateAll();
		panel_loanManager.updateAll();
		panel_viewReport.updateAll();
		panel_investmentPlan.updateAll();
	}
	
	public void undo()
	{
		int res = _shell.readCmd(CommandGenerator.sendUndoCmd());
		updateCRUDPanels(res);
	}
	
	public void redo()
	{
		int res = _shell.readCmd(CommandGenerator.sendRedoCmd());
		updateCRUDPanels(res);
	}
	
	public void gotoTabOverview()
	{
		if(curWindow!=null)
			curWindow.setVisible(false);
		curWindow = null;
		tabbedPane.setSelectedIndex(0);
	}
	public void gotoTabExpense()
	{
		if(curWindow!=null)
			curWindow.setVisible(false);
		curWindow = null;
		tabbedPane.setSelectedIndex(1);
	}
	public void gotoTabIncome()
	{
		if(curWindow!=null)
			curWindow.setVisible(false);
		curWindow = null;
		tabbedPane.setSelectedIndex(2);
	}
	public void gotoTabLoan()
	{
		if(curWindow!=null)
			curWindow.setVisible(false);
		curWindow = null;
		tabbedPane.setSelectedIndex(3);
	}
	public void gotoTabSearch()
	{
		if(curWindow!=null)
			curWindow.setVisible(false);
		curWindow = null;
		tabbedPane.setSelectedIndex(4);
	}
	public void gotoTabReport()
	{
		if(curWindow!=null)
			curWindow.setVisible(false);
		curWindow = null;
		tabbedPane.setSelectedIndex(5);
	}
	public void gotoTabInvest()
	{
		if(curWindow!=null)
			curWindow.setVisible(false);
		curWindow = null;
		tabbedPane.setSelectedIndex(6);
	}

	public void openSettingsMgrFrame(JFrame mgrFrame)
	{
		if(curWindow!=null)//two causes: 1. window open, 2. closed by GUI
		{
			if(curWindow.isVisible())//1. window open
			{
				curWindow.setVisible(false);
				if(curWindow.hashCode()!=mgrFrame.hashCode())
				{
					mgrFrame.setVisible(true);
					curWindow = mgrFrame;
				}
				else
				{
					curWindow = null;
				}
			}
			else//2. closed by GUI
			{
				curWindow = mgrFrame;
				mgrFrame.setVisible(true);
			}
		}
		else
		{
			curWindow = mgrFrame;
			mgrFrame.setVisible(true);
		}
		
	}
	public void setupSettingsFrames()
	{		
		frame_memMan.setContentPane(panel_memManager);
		frame_memMan.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
		frame_memMan.setBounds(ScreenAdjustment.getAlignCenterX(500), ScreenAdjustment.getAlignCenterY(300), 500, 300);
		frame_memMan.setTitle("Member Manager");
		frame_categoryMan.setContentPane(panel_categoryManager);
		frame_categoryMan.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
		frame_categoryMan.setBounds(ScreenAdjustment.getAlignCenterX(500), ScreenAdjustment.getAlignCenterY(300), 500, 300);
		frame_categoryMan.setTitle("Category Manager");
		frame_payMan.setContentPane(panel_payManager);
		frame_payMan.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
		frame_payMan.setBounds(ScreenAdjustment.getAlignCenterX(500), ScreenAdjustment.getAlignCenterY(300), 500, 300);
		frame_payMan.setTitle("Payment Method Manager");
		frame_aboutWindow.setContentPane(panel_aboutWindow);
		frame_aboutWindow.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
		frame_aboutWindow.setBounds(ScreenAdjustment.getAlignCenterX(500), ScreenAdjustment.getAlignCenterY(300), 500, 300);
		frame_aboutWindow.setTitle("About Window");
		frame_alertSetting.setContentPane(panel_alertManager);
		frame_alertSetting.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
		frame_alertSetting.setBounds(ScreenAdjustment.getAlignCenterX(410), ScreenAdjustment.getAlignCenterY(400), 410, 400);
		frame_alertSetting.setTitle("Alert Selection");
		frame_budgetSetting.setContentPane(panel_budgetSelection);
		frame_budgetSetting.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
		frame_budgetSetting.setBounds(ScreenAdjustment.getAlignCenterX(600), ScreenAdjustment.getAlignCenterY(300), 600, 300);
		frame_budgetSetting.setTitle("Budget Settings");
		frame_cliHelp.setContentPane(panel_cliHelp);
		frame_cliHelp.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
		frame_cliHelp.setBounds(ScreenAdjustment.getAlignCenterX(500), ScreenAdjustment.getAlignCenterY(300), 500, 300);
		frame_cliHelp.setTitle("Command Line Interface Help");
	}
}